package com.mengxuegu.springboot.task;

import com.mengxuegu.springboot.mapper.BankBillMapper;
import com.mengxuegu.springboot.service.ItemRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;


@Component
public class UpdateElastic {
    Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    BankBillMapper bankBillMapper;
    @Autowired
    ItemRepository itemRepository;
    @Scheduled(cron = "0 48 21 * * ?")
    public void updateelastic(){

        logger.info("定时更新elasticsearch --begin");
        itemRepository.saveAll(bankBillMapper.querySpendAll());
        logger.info("---end---");


    }
}
